\documentclass{article}
% translate with >> pdflatex -shell-escape <file>

% This file is used as unit test for pgfplots, copyright by Christian Feuersaenger.
% 
% See
%   http://pgfplots.sourceforge.net/pgfplots.pdf
% for pgfplots.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\pagestyle{empty}

\begin{document}


\begin{tikzpicture}
  \draw (0,0) rectangle (6,4);
  \begin{axis}[xshift=2.5cm, at={(0,0)}, anchor=outer south west, width=6cm, height=4cm, xlabel=$x$, ylabel=$y$, title={title}]
    \addplot function[domain={-3.1415:3.1415}]{sin(x)};
    \addlegendentry{$\sin(x)$}
  \end{axis}
\end{tikzpicture}
\end{document}
